package dm71.espil.activities;

import dm71.espil.R;
import dm71.espil.R.id;
import dm71.espil.R.layout;
import dm71.espil.REST.DataService;
import dm71.espil.models.Highscore;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HighscoreActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.highscore2);
		LinearLayout l = (LinearLayout) findViewById(R.id.mylayout1);
		LayoutInflater linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		DataService service = new DataService();
		Highscore[] highscores = service.GetHighscores(25);
		
		for (int i = 0; i < highscores.length; i++) 
		{ 
			View customView = linflater.inflate(R.layout.highscore, null);
			Highscore highscore = highscores[i];
			
			TextView tv = (TextView) customView.findViewById(R.id.TextView01);
			TextView tv2 = (TextView) customView.findViewById(R.id.TextView02);
			tv.setId(i);
			tv.setText("Navn:" + highscore.getUser().getName() + " " + highscore.getUser().getLastName());
			tv2.setId(i);
			tv2.setText(" Score: " + highscore.getScore());
			l.addView(customView);
		}
	}
}
